﻿using AdverseEventReportSystem.BLL;
using AdverseEventReportSystem.BLL.ServiceReference1;
using AdverseEventReportSystem.Core;
using AdverseEventReportSystem.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdverseEventReportSystem.Web.Areas.Sysbase
{
    public class PowerController : BaseController
    {
        // GET: Sysbase/Power
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 权限列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search()
        {
            string powerRole = WebUtils.GetString("powerRole");
            FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
            ResultHelperOfDataTable serviceResult = service.GetMenuNameList(-1, powerRole);
            DataTable dt = new DataTable();
            if (serviceResult.S)
            {
                dt = serviceResult.D;
            }

            var result = new { Rows = dt };
            return JsonDate(result);
        }

        /// <summary>
        /// 添加/编辑权限
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Save(string powerRole, tb_Power[] powList)
        {
            OperateResult resultInfo = PowerManager.Save(powerRole, powList);
            return JsonDate(resultInfo);
        }
    }
}